<template>
    <div>
        <van-tabs>
            <van-tab title="未收货">
                <div :class="['order-box-group',showItem?'List-Down':'List-Up']">
                    <img class="defpageB" src="../assets/defaultpage/own-goods.png" v-if="BereceivedList.length==0&&!showItem" alt="">
                    <div class="order-box" v-for="(item,index) in BereceivedList">
                        <div class="table-order-box">
                            <div class="order-left-img" :style="`background:url('http://www.starrymedia.vip${item.good.goods.left_img}')`"></div>
                            <div class="order-righr-text">
                                <van-cell-group>
                                    <van-cell title="订单编号" :value="item.order.order_sn" />
                                    <van-cell title="下单时间" :value="formateDate(item.order.add_time)" />
                                </van-cell-group>
                                <span class="order-money">￥{{item.order.total_amount}}</span>
                                <div class="order-btn-group">
                                    <span :class="['order-btn','order-btn-black']" @click="confirm(item.order)">确认收货</span>
                                    <span class="order-btn" @click="tagbox(index)">{{item.showDetail?'关闭':'查看物流'}}</span>
                                </div>
                            </div>
                        </div>
                        <div class="order-logistics-info" v-if="item.showDetail">
                            <div class="log-info-title">
                                收货地址
                            </div>
                            <van-cell-group>
                                <van-cell title="收件人" :value="item.address.user_name" />
                                <van-cell title="手机号">
                                    <template #default>
                                        <span style="font-family:'DINPro Medium';">{{item.address.phone}}</span>
                                    </template>
                                </van-cell>
                                <van-cell title="收货地址" :value="`${item.address.shi} ${item.address.qu} ${item.address.address}`" />
                            </van-cell-group>
                            <div class="log-info-title" style="margin-top:5px;margin-bottom:5px">
                                配送信息
                            </div>
                            <van-cell-group>
                                <van-cell title="配送公司" :value="item.order.log_name?item.order.log_name:'-'" />
                                <van-cell title="配送单号">
                                    <template #default>
                                        <span style="font-family:'DINPro Medium';">{{item.order.log_sn?item.order.log_sn:'-'}}</span>
                                    </template>
                                </van-cell>
                                <van-cell title="配送时间">
                                    <template #default>
                                        <span style="font-family:'DINPro Medium';">{{item.order.shipping_time?item.order.shipping_time:'-'}}</span>
                                    </template>
                                </van-cell>
                            </van-cell-group>
                        </div>
                    </div>
                </div>
                
                
            </van-tab>
            <van-tab title="已收货">
                <div :class="['order-box-group',showItem?'List-Down':'List-Up']">

                    <img class="defpageB" src="../assets/defaultpage/own-goods.png" v-if="receivedList.length==0&&!showItem" alt="">
                    <div class="order-box" v-for="(item,index) in receivedList">
                        <div class="table-order-box">
                            <div class="order-left-img" :style="`background:url('http://www.starrymedia.vip${item.good.goods.left_img}')`"></div>
                            <div class="order-righr-text">
                                <van-cell-group>
                                    <van-cell title="订单编号" :value="item.order.order_sn" />
                                    <van-cell title="下单时间" :value="formateDate(item.order.add_time)" />
                                </van-cell-group>
                                <span class="order-money">￥{{item.order.total_amount}}</span>
                                <div class="order-btn-group">
                                    <span class="order-btn" @click="JumptoDetail(item.order.order_id)">查看详情</span>
                                </div>
                            </div>
                        </div>
                    </div>


                </div>
            </van-tab>
        </van-tabs>
    </div>
</template>
<script>
import {_ajaxis_yes} from '../service/order'
export default {
    props:['showItem','BereceivedList','receivedList'],
    data(){
        return{
            orderLogistics:true
        }
    },
    methods:{
        JumptoDetail(id){
            this.$router.push({path:"/orderDetail",query:{oid:id}})
        },
        formateDate(time){
            return moment(time*1000).format('YYYY-MM-DD HH:mm:ss')
        },
        confirm(item){
            let _this=this

            if(item.log_name==""){
                _this.$toast("亲~正在路上呢")
                return
            }

            this.$dialog.confirm({
                title: '提示',
                message: '确认商品已送达？',
                overlayClass:'markbg',
                className:'logbase',
                getContainer:'.order-box-group'
            })
            .then(() => {
                let uid=JSON.parse(localStorage.getItem("user")).user_id
                _ajaxis_yes({
                    order_id:item.order_id,
                    user_id:uid
                }).then(res=>{
                    if(res.errcode==1){
                        _this.$emit("confirmOrd")
                    }else if(res.errcode==-1){
                        _this.$toast(res.message)
                    }
                    console.log(res)
                })
            })
            .catch(() => {
                // on cancel
            });
            
        },
        tagbox(i){
            this.$emit("BereceivedChange",i)
        }
    }
}
</script>
<style lang="less" scoped>
.font-SC(){
    font-family: "PingFang SC","Microsoft YaHei";
}
    /deep/.van-tabs__wrap{
        height: 53px;
        background-color: #f8f8f8;
    }
    /deep/.van-tabs__nav--line{
        height: 53px; 
        width: 180px;   
        margin: 0 auto;
        background-color: #f8f8f8;
    }
    /deep/.van-tab__text{
        .font-SC();
        font-weight: bold;
        color: #999;
        font-size: 12px;
    }
    /deep/.van-tabs__line{
        width: 30px !important;
        height: 3px;
        background-color: #000;
        bottom: 30px;
        // border-radius: 30%;
        box-shadow: 2px 2px 4px rgba(51, 51, 51, .47);
    }
    /deep/.van-tab--active .van-tab__text{
        color: #333;
    }

    .order-box-group{
        width: 100%;
        position: fixed;
        top: 256px;
        bottom: 0;
        left: 0;
        right: 0;
        overflow-y: auto;
        .defpageB{
            width: 127px;
            position: relative;
            top: 50px;
            left: 35%;
        }

        // /deep/.van-dialog{
        //     background-color: rgba(50, 50, 51, 0.88);
        //     /deep/.van-dialog__header{
        //         background-color: rgba(50, 50, 51, 0.88);
        //         color: #fff;
        //     }
        //     /deep/.van-dialog__message{
        //         background-color: rgba(50, 50, 51, 0.88);
        //         color: #fff;
        //     }
        //     /deep/.van-dialog__footer{
        //         /deep/button{
        //             background-color: rgba(50, 50, 51, 0.88);
        //             color: #fff;
        //         }
        //     }
        // }
        .order-box{
            width: 100%;
            height: auto;
            padding: 15px 15px 0 15px;
            background-color: #fff;
            margin-top: 10px;
            &:first-child{
                margin-top: 0px;
            }
            .table-order-box{
                width: 100%;
                height: 92px;
                .order-left-img{
                    display: inline-block;
                    width: 65px;
                    height: 77px;
                    background-position: center !important;
                    background-size: contain !important;
                    background-repeat: no-repeat !important;
                }
                .order-righr-text{
                    width: 253px;
                    display: inline-block;
                    height: 77px;
                    margin-left: 25px;
                    vertical-align: top;
                    /deep/.van-cell{
                        padding: 0;
                        .font-SC();
                        font-size: 12px;
                        color: #999;
                        line-height: 22px;
                    }
                    /deep/.van-cell:not(:last-child)::after{
                        display: none;
                    }
                    /deep/.van-cell__value{
                        font-family: "DINPro Medium";
                    }

                    .order-money{
                        width: 40%;
                        font-family: "DINPro-Bold";
                        font-size: 15px;
                        color: #333;
                        line-height: 21px;
                    }
                    .order-btn-group{
                        width: 58%;
                        float: right;
                        .order-btn{
                            display: inline-block;
                            float: right;
                            width: 60px;
                            height: 20px;
                            border: 1px solid #ccc;
                            border-radius: 5px;
                            .font-SC();
                            font-size: 12px;
                            color: #999;
                            text-align: center;
                            margin-left:10px;
                            margin-top: 12px;
                        }
                        .order-btn-black{
                            color: #fff;
                            background-color: #000;
                        }
                    }
                }
            }
            .order-logistics-info{
                width: 100%;
                height: auto;
                padding-top: 15px;
                background-color: #fff;
                padding-bottom: 15px;
                border-top: 1px solid #ccc;
                .log-info-title{
                    width: 100%;
                    .font-SC();
                    font-weight: bold;
                    font-size: 15px;
                    color: #333;
                }
                /deep/.van-cell{
                    padding: 0;
                    .font-SC();
                    font-size: 12px;
                    color: #999;
                    line-height: 22px;
                }
                /deep/.van-cell:not(:last-child)::after{
                    display: none;
                }
            }


        }
    }


    .List-Up{
        animation: ListUp ease .2s forwards;
        -moz-animation:ListUp ease .2s forwards ; /* Firefox */
        -webkit-animation:ListUp ease .2s forwards ; /* Safari and Chrome */
        -o-animation:ListUp ease .2s forwards ; /* Opera */
    }
    .List-Down{
        animation: ListDown ease .2s forwards;
        -moz-animation:ListDown ease .2s forwards ; /* Firefox */
        -webkit-animation:ListDown ease .2s forwards ; /* Safari and Chrome */
        -o-animation:ListDown ease .2s forwards ; /* Opera */
    }
    @keyframes ListUp {
        from{
            top: 2000px;
        }
        to{
            top: 256px;
        }
    }
    @keyframes ListDown {
        from{
            top: 256px;
        }
        to{
            top: 2000px;
        }
    }
</style>